﻿@model IEnumerable<BlogSite.Models.Blog>

@{
    ViewBag.Title = "Index";
    var count = Model.Count();
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Topic)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Post)
        </th>
        <th></th>
    </tr>
@if(count > 0){
    foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Topic)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Post)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { blogid=item.BlogId }) |
            @Html.ActionLink("Details", "Details", new { blogid=item.BlogId }) |
            @Html.ActionLink("Delete", "Delete", new { blogid=item.BlogId })
        </td>
    </tr>
    }
}
@if(count == 0){
      <tr>
          <td colspan="4" style="text-align:center;">No Data</td>
      </tr>
}

</table>
